package com.yiyi.credit.manage.sso.mapper;

import com.yiyi.credit.manage.sso.common.mapper.CommonMapper;
import com.yiyi.credit.manage.sso.model.entity.SysRoleResource;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


public interface SysRoleResourceMapper extends CommonMapper<SysRoleResource> {

    @Select(" select T1.id,T1.sys_info_id sysInfoId,T1.sys_role_id sysRoleId,T1.sys_resource_id resourceId,"
            + "T1.resource_columns resourceColumns,T1.pid,T2.columns,T2.name,(case when T2.columns <> "
            + "'' then 'true' else 'false' end ) canEdit\n"
            + " from sys_role_resource T1 left JOIN sys_resource T2 on T1.sys_resource_id = T2.id \n"
            + " where T1.sys_info_id=#{sysInfoId} and T1.sys_role_id = #{sysRoleId} ")
    List<Map<String, Object>> getSysRoleColumnsTree(@Param("sysInfoId") Long sysInfoId, @Param("sysRoleId") Long sysRoleId);

}
